national_data_inter <-national_data %>% mutate(condition2=dplyr::recode(condition, `1` = 0,`2` = 1))

out <- interflex(Y = "yes", D = "condition2", X = "rank", data = national_data_inter, theme.bw = TRUE, estimator = "kernel", nboots = 200, parallel = TRUE, cores = 4)

interflex_plot <- out$figure +
	theme(panel.spacing = unit(1, "lines")) + 
	theme(panel.grid.major = element_line(colour = "white"),panel.grid.minor = element_line(colour = "white"), axis.title.x = element_text(vjust=-0.5)) +
	xlab("Department Rank") +
	ylab("Marginal Effect of Ranking Treatment\non Agreeing to Discuss Collaboration ")

ggsave(plot = interflex_plot, "results/interflex_plot.pdf", width=4.5, height=4)